﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;

namespace TRIG_MOD_DASHBOARDS.CompletedTasksByPerson
{
    public partial class CompletedTasksByPersonUserControl : UserControl
    {
        private static string Entity { get; set; }
        DataForUsersTasks objCls = new DataForUsersTasks();

        protected void Page_Load(object sender, EventArgs e)
        {
            errorMsg.Text = "";
            objCls.errorMsg = errorMsg;
            Entity = Entities(Convert.ToString(objCls.GetUserEntity()));
            if (IsPostBack) { }
            else
            { objCls.getEntityUsers(ddlTaskPerson, Entity); }
        }

        private static string Entities(string QS)
        {
            string ent = "";
            if (QS == "CNT") { ent = "Contractor"; } else if (QS == "CNS") { ent = "Consultant"; } else ent = "Client";
            return ent;
        }

        protected void ddlTaskPerson_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void gvUserCompleteTasks_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            objCls.Row_Data_Bind(e, "Complete");
        }

        protected void gvUserCompleteTasks_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvUserCompleteTasks.PageIndex = e.NewPageIndex;
            gvUserCompleteTasks.DataBind();
        }

        protected void btnCompleteShow_Click(object sender, EventArgs e)
        {
            int gvCount = 0;
            try
            {
                gvCount = objCls.FormLoadBindData(ddlTaskPerson.SelectedValue, gvUserCompleteTasks, "Completed");
            }
            catch (Exception x)
            {
                objCls.ErrLos(x);
            }
           
            if (gvCount > 0) { gvUserCompleteTasks.Visible = true; errorMsg.Text = ""; } else { gvUserCompleteTasks.Visible = false; errorMsg.Text = "No Records found"; errorMsg.ForeColor = System.Drawing.Color.Green; }
        }




    }
}

